package com.hundsun.data.po;

import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;

import java.io.Serializable;
import java.util.Objects;

@Data
public class TableInfoPo implements Serializable {

    /**
     * 数据源类型
     */
    @Excel(name = "数据库类型", orderNum = "0")
    private String dataSourceType;

    /**
     * 表名
     */
    @Excel(name = "表名", orderNum = "1")
    private String tableName;

    /**
     * 列名
     */
    @Excel(name = "列名", orderNum = "2")
    private String columnName;

    /**
     * 字段类型。如：varchar(255) 里的 varchar
     */
    @Excel(name = "字段类型", orderNum = "3")
    private String dataType;

    /**
     * 数据类型长度。如：varchar(255) 里的 255
     */
    @Excel(name = "长度", orderNum = "4")
    private Long charMaxLength;

    /**
     * 小数点前面的数字。如：decimal(19,2) 里的 19
     */
    @Excel(name = "小数点前", orderNum = "5")
    private Long numericPrecision;

    /**
     * 小数点后的数字。如：decimal(19,2) 里的 2
     */
    @Excel(name = "小数点后", orderNum = "6")
    private Long numericScale;

    /**
     * 列的完整类型。如：varchar(255)  decimal(19,2) unsigned
     */
    @Excel(name = "列的完整类型", orderNum = "7")
    private String columnType;

    @Excel(name = "字段默认值", orderNum = "8")
    private String dataDefault;



    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        TableInfoPo infoPo = (TableInfoPo) o;
        return Objects.equals(tableName.toUpperCase(), infoPo.tableName.toUpperCase())
                && Objects.equals(columnName.toUpperCase(), infoPo.columnName.toUpperCase())
                && Objects.equals(dataType.toUpperCase(), infoPo.dataType.toUpperCase())
                && Objects.equals(charMaxLength, infoPo.charMaxLength)
//                && Objects.equals(numericPrecision, infoPo.numericPrecision)
//                && Objects.equals(numericScale, infoPo.numericScale)
//                && Objects.equals(dataDefault, infoPo.dataDefault)
                && Objects.equals(columnType.toUpperCase(), infoPo.columnType.toUpperCase());
    }

    @Override
    public int hashCode() {
        return Objects.hash(tableName.toUpperCase(), columnName.toUpperCase(), dataType.toUpperCase(), charMaxLength, dataDefault, columnType.toUpperCase());
    }
}
